<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>简单计数器</title>
</head>
<body>
    <h2>计数器</h2>
    <p>当前值: <span id="count">5</span></p >
    <button id="increase">增加</button>
    <button id="decrease">减少</button>

    <script>
        // 获取页面元素
        const countElement = document.getElementById('count');
        const increaseButton = document.getElementById('increase');
        const decreaseButton = document.getElementById('decrease');

        // 增加按钮点击事件
        increaseButton.addEventListener('click', function() {
            let count = parseInt(countElement.textContent);
            count++;
            countElement.textContent = count;
        });

        // 减少按钮点击事件
        decreaseButton.addEventListener('click', function() {
            let count = parseInt(countElement.textContent);
            if (count > 0) {
                count--;
                countElement.textContent = count;
            }
        });
    </script>
</body>
</html>